<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>浏览器回话存储</title>
    <script type="text/javascript" src="../../../public/vue.js"></script>
</head>
<body>
    <h1>浏览器回话存储</h1>
    <button onclick="saveData()"> 点我新增一个保存数据</button>
    <button onclick="getData()"> 点我读取一个保存数据</button>
    <script>
        const p = {'张三':'18'};
        function saveData() {
            window.sessionStorage.setItem('name', '张三')
            window.sessionStorage.setItem('person', JSON.stringify(p))
       }
       function getData(){
            console.log(window.sessionStorage.getItem('name'))
            console.log(window.sessionStorage.getItem('person'))
       }
    </script>
</body>
</html>